home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / DVIM72-Mac 1.9.6 / source / ACTFACT.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-14  |  2.8 KB  |  86 lines  |  [TEXT/R*ch]

  1. /* -*-C-*- actfact.h */
  2. /*-->actfact*/
  3. /**********************************************************************/
  4. /****************************** actfact *******************************/
  5. /**********************************************************************/
  6. #include "dvihead.h"
  7. #include "commands.h"
  8. #include "gendefs.h"
  9. #include "gblprocs.h"
  10. #include "egblvars.h"
  11. #include "m72.h"
  12. #include "mac-specific.h"
  13.  
  14. float
  15. actfact(unmodsize)
  16. register UNSIGN32 unmodsize;
  17.  
  18. /***********************************************************************
  19. Compute the actual size factor given the integer approximation unmodsize
  20. = (magnification  factor)*1000.   Values  not found  in  the  table  are
  21. rounded to the nearest table  entry; this ensures that rounding  errors,
  22. or  user  magnification  parameter  input  errors  result  in  something
  23. reasonable.  mag_table[] has a  wider range of magnifications  available
  24. than most sites will have, and can be used to find a nearest match  font
  25. when one is missing.
  26. ***********************************************************************/
  27.  
  28. {
  29.     register INT16 k;
  30.     register UNSIGN32 tab_entry;
  31.  
  32.     for (k = 1; k < MAGTABSIZE; ++k)
  33.     {
  34.     tab_entry = MAGSIZE(mag_table[k]);    /* round entry */
  35.     if (unmodsize < tab_entry) /* choose nearer of k-1,k entries */
  36.     {
  37.         if (unmodsize < MAGSIZE((mag_table[k-1] + mag_table[k])/2.0))
  38.             k--;            /* choose smaller one */
  39.         break;
  40.     }
  41.     else if (unmodsize == tab_entry)
  42.         break;
  43.     }
  44.     mag_index = ((k < MAGTABSIZE) ? k : (MAGTABSIZE-1));/* set global index */
  45.     return((float)mag_table[mag_index]);
  46. }
  47.  
  48.  
  49. float
  50. actfact_res(unmodsize)
  51. register UNSIGN32 unmodsize;
  52.  
  53. /***********************************************************************
  54. Compute the actual size factor given the integer approximation unmodsize
  55. relative to the resolution.  For instance at 72dpi we might see numbers
  56. around 360.  Values  not found  in  the  table  are
  57. rounded to the nearest table  entry; this ensures that rounding  errors,
  58. or  user  magnification  parameter  input  errors  result  in  something
  59. reasonable.  mag_table[] has a  wider range of magnifications  available
  60. than most sites will have, and can be used to find a nearest match  font
  61. when one is missing.
  62. ***********************************************************************/
  63.  
  64. {
  65.     register INT16 k;
  66.     register UNSIGN32 tab_entry;
  67.     float resfact = RESOLUTION / 200.0;
  68.  
  69.     for (k = 1; k < MAGTABSIZE; ++k)
  70.     {
  71.         tab_entry = MAGSIZE(mag_table[k]*resfact);    /* round entry */
  72.         if (unmodsize < tab_entry) /* choose nearer of k-1,k entries */
  73.         {
  74.             if (unmodsize < MAGSIZE(resfact*(mag_table[k-1] + mag_table[k])/2.0))
  75.                 k--;            /* choose smaller one */
  76.                break;
  77.         }
  78.         else if (unmodsize == tab_entry)
  79.             break;
  80.     }
  81.     mag_index = ((k < MAGTABSIZE) ? k : (MAGTABSIZE-1));/* set global index */
  82.     return((float)mag_table[mag_index]*resfact);
  83. }
  84.  
  85.  
  86.